import * as React from "react"
import { useEffect } from "react"

interface PopstateProps {
  onPop: (event: PopStateEvent) => void
}

export default function Popstate(props: PopstateProps) {
  const { onPop } = props
  console.log(onPop)
  useEffect(() => {
    const handlePop = (event: PopStateEvent) => {
      onPop(event)
    }
    window.addEventListener("popstate", handlePop, false)
    return () => {
      console.log("remove")
      window.removeEventListener("popstate", handlePop)
    }
  }, [onPop])

  return <></>
}
